package com.ponhu.ea2.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ponhu.ea2.scmcenter.model.enums.procurement.ProcurementTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Wang
 * @date 2021/12/13 6:46 下午
 */
@ApiModel("采购数据")
@Data
@Accessors(chain = true)
public class PickInventoryPurchaseVo implements Serializable {
    private static final long serialVersionUID = 4150440135754559645L;

    @ApiModelProperty("货品编码")
    private String inventoryCode;

    @JsonIgnore
    @ApiModelProperty(value = "入库方式", hidden = true)
    private Integer warehouseType;

    @ApiModelProperty("入库方式")
    private String warehouseTypeName;

    @JsonIgnore
    @ApiModelProperty(value = "采购类型ID，多个逗号分隔", hidden = true)
    private String procurementTypes;

    @JsonIgnore
    @ApiModelProperty(value = "采购类型", hidden = true)
    private Integer procurementType;

    @ApiModelProperty("采购类型")
    private String procurementTypeName;

    @ApiModelProperty("采购渠道")
    private String channelName;

    @ApiModelProperty("供应商")
    private String suppName;

    public String getProcurementTypeName() {
        if (ObjectUtils.isNotEmpty(procurementType))
            return ProcurementTypeEnum.getEnum(this.procurementType).getName();
        if (StringUtils.isNotEmpty(procurementTypes)) {
            List<String> typeList = Arrays.asList(procurementTypes.split(","));
            return Arrays.stream(ProcurementTypeEnum.values()).filter(e -> typeList.contains(e.getType().toString()))
                    .map(ProcurementTypeEnum::getName).collect(Collectors.joining(","));
        }
        return null;
    }

}
